import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';
import { payWayList } from './api';
import { vipcardList } from '@apps/ant-bus/src/views/business/goods/vipcard/data/api';
import { airportList } from '@apps/ant-bus/src/views/business/airport/data/api';
import { xunLianPayParamList } from '@apps/ant-bus/src/views/business/payset/xunlianPayparam/api';
import { yinLianPayParamList } from '@apps/ant-bus/src/views/business/payset/yinlianPayparam/api';
import { RenderType } from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 150,
  },
  {
    title: '会员账号',
    dataIndex: 'mainAccount',
    width: 120,
  },
  {
    title: '会员姓名',
    dataIndex: 'userName',
    width: 120,
  },
  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 120,
  },
  {
    title: '会员卡号',
    dataIndex: 'vipCardNo',
    width: 180,
  },
  {
    title: '开卡日期',
    dataIndex: 'buyDate',
    width: 120,
  },
  {
    title: '支付金额',
    dataIndex: 'payAmount',
    width: 120,
  },
  /* {
    title: '企业编码',
    dataIndex: 'companyCode',
    width: 120,
  },*/
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'mainAccount',
    label: '会员账号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'userName',
    label: '姓名',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'mobile',
    label: '手机号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'vipCardNo',
    label: '卡号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'employeeName',
    label: '销售',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'payType',
    label: '收款方式',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: ({ formActionType, formModel }) => {
      return {
        options: [
          { label: '全部', value: '' },
          { label: '讯联微信', value: 'PAY_WX' },
          { label: '银联微信', value: 'PAY_WX_YINLIAN' },
          { label: '线下支付', value: 'PAY_UNDERLINE' },
          { label: '扫码支付', value: 'PAY_QRCODE' },
        ],
        onChange: payType => {
          const { updateSchema } = formActionType;
          //所属部门修改后更新负责部门下拉框数据
          let componentProps = {};
          if (payType == 'PAY_WX' || payType == 'PAY_QRCODE') {
            componentProps = {
              api: xunLianPayParamList,
              labelField: 'paramName',
              valueField: 'xunlianPayparamId',
              immediate: true,
              showSearch: true,
            };
          }
          if (payType == 'PAY_WX_YINLIAN') {
            componentProps = {
              api: yinLianPayParamList,
              labelField: 'yinlianPayName',
              valueField: 'yinlianpayparamId',
              immediate: true,
              showSearch: true,
            };
          }
          if (payType == 'PAY_UNDERLINE') {
            componentProps = {
              api: payWayList,
              labelField: 'paywayName',
              valueField: 'paywayId',
              immediate: true,
              showSearch: true,
            };
          }
          updateSchema([
            {
              field: 'targetPayParamId',
              componentProps: componentProps,
            },
          ]);
          formModel.targetPayParamId = null;
        },
      };
    },
  },
  {
    field: 'targetPayParamId',
    label: '支付通道',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      placeholder: '请先选择收款方式',
    },
  },
  {
    field: 'payInfoId',
    label: '支付Id',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'goodsId',
    label: '卡种',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: vipcardList,
      params: { handlerName: 'busVipCardListHandler' },
      labelField: 'goodsName',
      valueField: 'goodsId',
      immediate: true,
      showSearch: true,
    },
  },
  {
    field: 'airportId',
    label: '开卡地',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: airportList,
      params: { handlerName: 'busAirportRoleListHandler' },
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
    },
  },
  {
    field: 'vipCardState',
    label: '状态',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '待激活', value: 0 },
        { label: '正常', value: 1 },
        { label: '已过期', value: 2 },
        { label: '未开通', value: 3 },
        { label: '未通过', value: 4 },
        { label: '冻结', value: 5 },
        { label: '退卡中', value: 6 },
        { label: '已退卡', value: 7 },
        { label: '已转卡', value: 8 },
        { label: '已转赠', value: 9 },
        { label: '冻结（延时开通）', value: 10 },
      ],
    },
  },
  {
    field: 'sourceType',
    label: '来源',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '扫码注册', value: 1 },
        { label: '公众号购买', value: 2 },
        { label: '销售新增', value: 3 },
        { label: '后台新增', value: 4 },
        { label: '后台导入', value: 5 },
        { label: '礼品卡接收', value: 6 },
        { label: '后台批量生成', value: 7 },
        { label: '销售赠送', value: 8 },
        { label: '代理商下单', value: 9 },
        { label: '企业下单', value: 10 },
        { label: '后台券码生成', value: 11 },
      ],
    },
  },
  {
    field: 'isBenCompany',
    label: '会员属性',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '全部会员', value: '' },
        { label: 'CXZS', value: 0 },
        { label: 'XSSK', value: 1 },
      ],
    },
  },
  /* {
    label: '企业编码',
    field: 'companyCode',
    component: 'Input',
  },*/
  {
    field: 'startDate',
    label: '开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
];
